/*
 * @Description: 利用权限reducer
 * @Author: Rfan
 * @Date: 2022-04-07 15:49:26
 * @LastEditTime: 2022-05-25 09:01:21
 */

import { SAVE_FORM_LINK, SET_RIGHTS_LIST, SET_SELECT_AT, SET_SELECT_FOND } from '../constants';

export const UseRightReducer = (state, action) => {
  switch (action.type) {
    /**
     * @description: 表格加载loading
     */
    case SET_SELECT_FOND:
      return {
        ...state,
        selectFond: action.data
      };

    /**
     * @description: 设置选中的档案类型
     * @param {object} data 选中的档案类型
     */
    case SET_SELECT_AT:
      return {
        ...state,
        selectAT: action.data
      };

    /**
     * @description: 设置默认权限列表
     * @param {any[]} list 默认权限列表
     */
    case SET_RIGHTS_LIST:
      return {
        ...state,
        rightsList: action.list
      };

    /**
     * @description: 设置表单form
     * @param {FormInstance} data 表单form
     */
    case SAVE_FORM_LINK:
      return {
        ...state,
        formLink: action.data
      };

    default:
      console.log('untouched', action);
      return state;
  }
};
